
<template>
  <el-select v-model="jijianKeyId" size="small" style="width:100%" filterable clearable @change="returnChange" placeholder="请选择基建项目" >
    <el-option 
      v-for="item in jijianList" 
      :key="item.jjId" 
      :label="item.jjName" 
      :value="item.jjId">
    </el-option>
  </el-select>
</template>

<script>
import { listJijianerji } from "@/api/erp/system/jijianerji";

export default {
  data() {
    return {
      jijianList : [],
      jijianKeyId : '',
    };
  },
  model:{
    prop:'jijianId', 
    event: 'change'
  },
  watch:{
    jijianId : function(newValue, oldValue){
      this.jijianKeyId = newValue;
    },
    workshopId:function(newValue, oldValue){
      listJijianerji({workshopId: newValue}).then((response) => {
        this.jijianList = response.rows;
      });
    }
  },
  props: {
    //用于绑定和初始选中的基建ID
    jijianId: 0,
    //生产线ID
    workshopId: 0,
  },
  methods: {
    returnChange(){
      this.$emit('change', this.jijianKeyId);
    },
  },
  created() {
    listJijianerji({workshopId: this.workshopId}).then((response) => {
        this.jijianList = response.rows;
    });
  },
};
</script>
